package org.demo.thread.stop;

import java.util.concurrent.TimeUnit;

/**
 * @Author:LiaoYouLe
 * @Date: Created in 2018/9/27
 * @Description
 * @Modifyied By:
 */
public class StopExmple {

    static class StopTask implements Runnable {
        @Override
        public void run() {
            int i = 0;
            while (true) {
                System.err.println(i++);
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread task = new Thread(new StopTask());
        task.start();
        System.err.println(task.isAlive());
        TimeUnit.SECONDS.sleep(10);
        task.stop();
        System.err.println(task.isAlive());
        System.err.println(task.isInterrupted());
    }


}
